home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_dat.lzh / csep_pdpsprlg next >
Text File  |  1991-12-16  |  5KB  |  218 lines

  1. %======================================================================%
  2. % Professional Draw Color Seperation Prologue file: V3.0, Dec 16, 1990 %
  3. %======================================================================%
  4. %
  5. % Handles function re-mapping for Color seperation of documents with EPSF files
  6. % with PostScript color commands: 'setrgbcolor, sethsbcolor' as well as
  7. % ColorPostScript commands: `setcmykcolor, currentcmykcolor, colorimage,
  8. % setcolorscreen, currentcolorscreen' + transfer and UCR/GCR commands.
  9.  
  10. % "component" is a global variable = 0 which specifies the seperation we're
  11. %  currently doing:  = 0 for B&W black, 1 for black, 2 for y, 3 for m,
  12. %               4 for c, 5 for mechanical (custom) colors
  13. /component 0 def
  14. /subgray true def
  15. /fourcol false def   % used to designate 3 or 4 colour sep.
  16. /setrgb /setrgbcolor load def
  17. /sethsb /sethsbcolor load def
  18. /_setgray /setgray load def
  19. /UCR_fctr 1.0 def
  20. /GCR_fctr 1.0 def
  21.  
  22. %
  23. % setgray
  24. %
  25. /setgray {   % g setgray
  26.    subgray
  27.    {
  28.       component 0 eq component 1 eq or not
  29.       { pop 1.0 }
  30.       if
  31.    }
  32.    if
  33.    _setgray
  34. } bdef
  35.  
  36. %
  37. % Standard PostScript operators:
  38. %
  39.  
  40. % translate rgb into cmyk with 100% UCR/GCR
  41. /setrgbcolor {    % red grn blu setrgbcolor
  42.    % call system setrgbcolor so that currentrgbcolr, currenthsbcolor
  43.    % will still give correct results:
  44.    3 copy setrgb
  45.  
  46.    5 dict begin
  47.  
  48.    1 exch sub /ye exch def
  49.    1 exch sub /ma exch def
  50.    1 exch sub /cy exch def
  51.    /blk 0 def
  52.  
  53.    fourcol { % do 100% UCR/GCR
  54.       /min ye def
  55.       ma min lt {/min ma def} if
  56.       cy min lt {/min cy def} if
  57.       min UCR_fctr mul /blk exch def
  58.  
  59.       ye blk sub /ye exch def
  60.       ma blk sub /ma exch def
  61.       cy blk sub /cy exch def
  62.       min GCR_fctr mul /blk exch def
  63.  
  64.    } if
  65.  
  66.    % get the component that we want:
  67.    component 0 eq {blk 3 mul ma add ye add cy add 3 div} if
  68.    component 1 eq {blk} if
  69.    component 2 eq {ye} if
  70.    component 3 eq {ma} if
  71.    component 4 eq {cy} if
  72.    component 5 eq {0} if
  73.    1 exch sub _setgray
  74.  
  75.    end
  76. } bdef
  77.  
  78. /sethsbcolor {
  79.    sethsb currentrgbcolor setrgbcolor
  80. } bdef
  81.  
  82. %
  83. % Color PostScript operators:
  84. %
  85.  
  86. /setcmykcolor {  % cy ma ye blk setcmykcolor
  87.    1 sub 4 1 roll
  88.    3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat
  89.    setrgbcolor pop
  90. } bdef
  91.  
  92. /currentcmykcolor {
  93.    currentgray dup dup dup
  94. } bdef
  95.  
  96. /setcolorscreen {
  97.    component 0 eq {12 3 roll} if
  98.    component 1 eq {12 3 roll} if
  99.    component 2 eq {12 -6 roll} if
  100.    component 3 eq {12 -3 roll} if
  101.    % component 4 eq {} if
  102.    component 5 eq
  103.    {12 {pop} repeat}
  104.    {9 {pop} repeat setscreen}
  105.    ifelse
  106. } bdef
  107.  
  108. /currentcolorscreen {
  109.    currentscreen 3 copy 3 copy 3 copy
  110. } bdef
  111.  
  112. /setcolortransfer {
  113.    component 0 eq {4 1 roll} if
  114.    component 1 eq {4 1 roll} if
  115.    component 2 eq {4 -2 roll} if
  116.    component 3 eq {4 -1 roll} if
  117.    % component 4 eq {} if
  118.    component 5 eq
  119.    { pop pop pop pop}
  120.    {pop pop pop settransfer}
  121.    ifelse
  122. } bdef
  123.  
  124. /currentcolortransfer {
  125.    currenttransfer dup dup dup
  126. } bdef
  127.  
  128. /setblackgeneration {
  129.    pop
  130. } bdef
  131. /currentblackgeneration {
  132.    {}
  133. } bdef
  134.  
  135. /setundercolorremoval {
  136.    pop
  137. } bdef
  138.  
  139. /currentundercolorremoval {
  140.    {}
  141. } bdef
  142.  
  143. /colorimage { % width height bps matrix proc0 [...procn-1] multi ncol colorimage
  144.    10 dict begin
  145.    /ncol exch def
  146.    /multi exch def
  147.    ncol 4 eq multi and {
  148.       /proc3 exch def
  149.    } if
  150.    ncol 3 ge multi and {
  151.       /proc2 exch def
  152.       /proc1 exch def
  153.    } if
  154.    /proc0 exch def
  155.    /mat exch def
  156.    /bps exch def
  157.    /height exch def
  158.  
  159.    height bps mat
  160.  
  161.    ncol 1 eq
  162.    {    % just B&W data
  163.       component 0 eq component 1 eq or
  164.       {{proc0} image}
  165.       {height {proc0 pop} repeat 4 {pop} repeat}
  166.       ifelse
  167.    }
  168.    {
  169.       multi
  170.       {
  171.      /trsave currenttransfer def
  172.      % CMYK (4 color) is dark-high, `image' wants light-high
  173.      % so invert image:
  174.      ncol 4 eq {{1 exch sub} currenttransfer concatprocs settransfer} if
  175.      component 0 eq component 1 eq or { % B&W or Black component
  176.         ncol 3 eq
  177.         {height {proc0 pop proc1 pop proc2 pop} repeat 4 {pop} repeat}
  178.         {{proc0 pop proc1 pop proc2 pop proc3} image}
  179.         ifelse
  180.      } if
  181.      component 2 eq { % Yellow component
  182.         ncol 3 eq
  183.         {{proc0 pop proc1 pop proc2} image}
  184.         {{proc0 pop proc1 pop proc2 proc3 pop} image}
  185.         ifelse
  186.      } if
  187.      component 3 eq { % Magenta component
  188.         ncol 3 eq
  189.         {{proc0 pop proc1 proc2 pop} image}
  190.         {{proc0 pop proc1 proc2 pop proc3 pop} image}
  191.         ifelse
  192.      } if
  193.      component 4 eq { % Cyan component
  194.         ncol 3 eq
  195.         {{proc0 proc1 pop proc2 pop} image}
  196.         {{proc0 proc1 pop proc2 pop proc3 pop} image}
  197.         ifelse
  198.      } if
  199.      component 5 eq { % Mechanical color
  200.         ncol 3 eq
  201.         {height {proc0 pop proc1 pop proc2 pop} repeat 4 {pop} repeat}
  202.         {height {proc0 pop proc1 pop proc2 pop proc3 pop} repeat 4 {pop} repeat }
  203.         ifelse
  204.      } if
  205.      /trsave load settransfer
  206.       }
  207.       {  % not multiproc - can't do anything
  208.      height {proc0 pop} repeat 4 {pop} repeat
  209.       }
  210.       ifelse
  211.    }
  212.    ifelse
  213.    end
  214. } bdef
  215.  
  216.  
  217.  
  218.